Ext.define('Fxt.st-account.Controller', {
    extend: 'Fxt.core.CrudController',
    stores: 'Fxt.st-account.Store',
    models: ['Fxt.st-account.Model'],
    views: ['Fxt.st-account.view.Viewport', 'Fxt.st-account.view.Grid', 'Fxt.st-account.view.QueryForm'],
    $onInit: function() {
        var me = this;
        var queryForm = me.$getViewport().$getQueryForm();
        var grid = me.$getViewport().$getGrid();
        var module = me.$getModule();
        this.control({
            'button[action=new-register]': {
                click: function(btn) {
                    var grid = me.$getViewport().$getGrid();
                    Fxt.selectOneRow(grid, function(record) {
                        var promotionCode = record.get("promotionCode");
                        Fxt.ajax({
                            method: 'POST',
                            url: '/st-account/new-register',
                            params: {
                                promotionCode: promotionCode
                            },
                            success: function (data) {
                                Fxt.success('注册成功, 手机号为：' + data);
                            }
                        });
                    });
                }
            }
        });
    }
});